import java.util.List;
public class MeiyouStudy {
        private double averageCycleLength;

        public void train(List<Integer> cycleLengths) {
            int sum = 0;
            for (int length : cycleLengths) {
                sum += length;
            }
            averageCycleLength = (double) sum / cycleLengths.size();
        }

        public int predictNextPeriod(int lastPeriodDay) {
            return lastPeriodDay + (int) averageCycleLength;
        }

        public void updateModel(int actualCycleLength) {
            averageCycleLength = (averageCycleLength + actualCycleLength) / 2;
        }
    }

